package com.itheima.servie;

import com.itheima.dao.StudentDao;
import com.itheima.domain.Student;

import java.util.ArrayList;

public class StudentService {
    private StudentDao dao= new StudentDao();

    public void addStudent(Student student){
       dao.addstudent(student);
    }
    public void deleteStudentBySid(String sid){
      dao.deleteStudentBySid(sid);
    }
    public void updateStudent(String  sid,Student newStu){
      dao.updateStudent(sid, newStu);
    }
    public ArrayList<Student> findAllStudents(){
        return dao.findAllstudents();
    }

    public boolean isExist(String sid){
        ArrayList<Student> list = dao.findAllstudents();
        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            if(student.getSid().equals(sid)){
                return true;
            }
        }
        return false;
    }
}
